<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ include file="/WEB-INF/page/common/commonPage.jsp"%>
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>内容类型管理</title>
    <link rel="stylesheet" type="text/css" href="${resourcesUrl}/common/css/bootstrap.min.css">
    <link rel="stylesheet" type="text/css" href="${resourcesUrl}/common/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="${resourcesUrl}/common/css/smartadmin-production.min.css">
</head>
<body>
    <%@ include file="/WEB-INF/page/common/header.jsp"%>
    <%@ include file="/WEB-INF/page/common/leftSideBar.jsp"%>

    <div id="main" role="main">
        <div id="ribbon">
            <ol class="breadcrumb">
                <li>首页</li>
                <li>内容类型管理</li>
            </ol>
        </div>
        <div id="content">
            <div class="row">
                <div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
                    <div class="jarviswidget">
                        <header>
                            <h2><i class="fa fa-list"></i> 内容类型列表</h2>
                        </header>
                        <div class="widget-body">
                            <div class="widget-body-toolbar">
                                <button type="button" class="btn btn-primary" onclick="window.location.href='${base}/contenttype/add'">
                                    <i class="fa fa-plus"></i> 添加内容类型
                                </button>
                            </div>
                            <table class="table table-striped table-hover">
                                <thead>
                                    <tr>
                                        <th>类型标识</th>
                                        <th>类型名称</th>
                                        <th>类型说明</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    <c:if test="${empty types}">
                                        <tr>
                                            <td colspan="4" class="text-center">暂无数据</td>
                                        </tr>
                                    </c:if>
                                    <c:forEach items="${types}" var="type">
                                        <tr>
                                            <td>${type.typeId}</td>
                                            <td>${type.typeName}</td>
                                            <td>${type.typeDesc}</td>
                                            <td>
                                                <button type="button" class="btn btn-xs btn-primary" onclick="window.location.href='${base}/contenttype/edit?typeId=${type.typeId}'">
                                                    <i class="fa fa-pencil"></i> 编辑
                                                </button>
                                                <button type="button" class="btn btn-xs btn-danger" onclick="deleteType('${type.typeId}')">
                                                    <i class="fa fa-trash-o"></i> 删除
                                                </button>
                                            </td>
                                        </tr>
                                    </c:forEach>
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script src="${resourcesUrl}/common/js/jquery-1.8.2.min.js"></script>
    <script src="${resourcesUrl}/common/js/bootstrap/bootstrap.min.js"></script>
    <script src="${resourcesUrl}/common/components/artDialog/dialog-min.js"></script>
    <script type="text/javascript">
        function deleteType(typeId) {
            dialog({
                title: '提示',
                content: '确定要删除该内容类型吗？',
                okValue: '确定',
                ok: function() {
                    $.ajax({
                        url: '${base}/contenttype/delete',
                        type: 'POST',
                        data: {
                            typeId: typeId
                        },
                        success: function(data) {
                            if(data.RET_CODE.toLowerCase() === 'success') {
                                dialog({
                                    title: '提示',
                                    content: '删除成功',
                                    ok: function() {
                                        window.location.reload();
                                    }
                                }).showModal();
                            } else {
                                dialog({
                                    title: '提示',
                                    content: data.RET_OBJ || '删除失败',
                                    ok: function() {}
                                }).showModal();
                            }
                        }
                    });
                },
                cancelValue: '取消',
                cancel: function() {}
            }).showModal();
        }
    </script>
    <%@ include file="/WEB-INF/page/common/footer.jsp"%>
</body>
</html> 